var pages = []; //页面列表
var rs = [];
var nowindex = 0; //当前页面记录器
var isok = true; //是否相应滚动
HTMLCollection.prototype.forEach=Array.prototype.forEach;
window.onload = function () {
    //获取页面domnode
    pages.push(document.getElementById('pageone'));
    pages.push(document.getElementById('pagetwo'));
    pages.push(document.getElementById('pagethr'));
    //获取页面选择器node
    rs.push(document.getElementById('rone'));
    rs.push(document.getElementById('rtwo'));
    rs.push(document.getElementById('rthr'));
    //
    var scrfun = function (e) {
        if (!isok) return;
        //        if (Math.abs(e.wheelDelta) < 120 * 5) return;
        var isup = e.wheelDelta > 0 ? true : false;
        if (isup) {
            if (nowindex == 0) return;
            var fel=pages[nowindex];
            fel.children[0].classList.remove('active');
            fel.children[1].classList.remove('active');
            rs[nowindex].removeAttribute('checked');
            rs[--nowindex].setAttribute('checked', 'checked');
        }
        else {
            if (nowindex == 2) return;
            var fel=pages[nowindex];
            fel.children[0].classList.remove('active');
            fel.children[1].classList.remove('active');
            rs[nowindex].removeAttribute('checked');
            rs[++nowindex].setAttribute('checked', 'checked');
        }
        isok = false;
        setTimeout(function() {
            var fel=pages[nowindex];
            fel.children[0].classList.add('active');
            fel.children[1].classList.add('active');
        }, 500);
        setTimeout(function () {
            isok = true;
        }, 1000);
    };
    for (var t = 0; t < pages.length; ++t) {
        var page = pages[t];
        page.onmousewheel = scrfun;
    }
}